//
//  RootLaundryCollectionViewCell.m
//  BaseFrame
//
//  Created by 吕金状 on 2017/8/1.
//  Copyright © 2017年 com.mxh. All rights reserved.
//

#import "RootLaundryCollectionViewCell.h"

@interface RootLaundryCollectionViewCell ()

Strong UILabel *titleLabel;
Strong UILabel *textLabel;
Strong UIImageView *titleImageView;
Strong UIView *lineView;
Strong UIView *line2View;

@end

@implementation RootLaundryCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        _titleLabel  = [[UILabel alloc]init];
        _titleLabel.font = DEF_FontSize_14;
        _titleLabel.textColor = getColor(textColor);
        [self.contentView addSubview:_titleLabel];
        
        _textLabel  = [[UILabel alloc]init];
        _textLabel.font = DEF_FontSize_14;
        _textLabel.textColor = getColor(mainColor);
        _textLabel.layer.borderColor = getColor(mainColor).CGColor;
        _textLabel.layer.borderWidth = 1;
        _textLabel.layer.masksToBounds = YES;
        _textLabel.layer.cornerRadius = 5;
        _textLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_textLabel];
        
        _titleImageView = [UIImageView new];
        _titleImageView.contentMode = UIViewContentModeScaleAspectFit;
        
        [self.contentView addSubview:_titleImageView];
        
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = getColor(dividerColor);
        [self.contentView addSubview:_lineView];
        
        _line2View = [[UIView alloc]init];
        _line2View.backgroundColor = getColor(dividerColor);
        [self.contentView addSubview:_line2View];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.titleLabel.frame = CGRectMake(10 / WIDTH_5S_SCALE, 6 / WIDTH_5S_SCALE, 100 / WIDTH_5S_SCALE, self.height / 2 );
    self.textLabel.frame = CGRectMake(10 / WIDTH_5S_SCALE, self.height / 2 + 5 / WIDTH_5S_SCALE , 90 / WIDTH_5S_SCALE, 15 / WIDTH_5S_SCALE);
    self.titleImageView.frame = CGRectMake(self.width - 50 / WIDTH_5S_SCALE, (self.height - 40 / WIDTH_5S_SCALE ) / 2, 40 / WIDTH_5S_SCALE, 40 / WIDTH_5S_SCALE);
    self.lineView.frame = CGRectMake(self.width, 0, 0.5, self.height);
    self.line2View.frame = CGRectMake(0, self.height, self.width, 0.5);
}

- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.titleImageView.image = [UIImage imageNamed:model[@"image"]];
    self.titleLabel.text = model[@"title"];
    self.textLabel.text = model[@"text"];
}

@end
